package com.cryptape.cita_wallet.activity;

import android.widget.TextView;
import android.widget.Toast;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.MapUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.cryptape.cita_wallet.CytonApplication;
import com.cryptape.cita_wallet.bean.LightNodeBean;
import com.cryptape.cita_wallet.net.callback.CommonCallback;
import com.cryptape.cita_wallet.net.request.HttpRequestMode;
import com.cryptape.cita_wallet.service.http.TokenService;
import com.cryptape.cita_wallet.util.RSAUtils;
import com.cryptape.cita_wallet.util.db.DBWalletUtil;
import com.mangoworld.android.R;

import java.util.Map;

import rx.Subscriber;

;

/**
 * Created by dengming on 13/1/20.
 */

public class MangoNodeActivity extends NBaseActivity {
    //    private List<MangoItemBean> mData = new ArrayList<>();
//    private MangoNodeBean mData;
    private TextView nodeName;
    private TextView tv_allNodeNum;
    private TextView tv_yesterday;
    private TextView yesterdayPool;
    private TextView tv_teamSmallNum;
    private TextView tv_teamSmallValue;
    private TextView tv_nodeLevel;

    @Override
    protected int getContentLayout() {
        return R.layout.activity_mango_node;
    }

    @Override
    protected void initView() {
        tv_allNodeNum = findViewById(R.id.tv_allNodeNum);
        nodeName = findViewById(R.id.nodeName);
        tv_yesterday = findViewById(R.id.tv_yesterday);
        tv_teamSmallValue = findViewById(R.id.tv_teamSmallValue);
        tv_teamSmallNum = findViewById(R.id.tv_teamSmallNum);
        tv_nodeLevel = findViewById(R.id.tv_nodeLevel);
    }

    @Override
    protected void initData() {
        String address = DBWalletUtil.getCurrentWallet(CytonApplication.getInstance()).address;
        try {
            Map params = MapUtils.newHashMap();
            params.put("address", address);
            String jsonData = GsonUtils.toJson(params);
            String content = RSAUtils.encrypt(jsonData);
            HttpRequestMode.getNodeIndex(MangoNodeActivity.this, content, true, new CommonCallback() {
                @Override
                public void onSuccess(Object data, String successMsg, int responseSuccessCode) {
                    if (data != null) {
                        LightNodeBean lightNodeBean = (LightNodeBean) data;
                        tv_allNodeNum.setText(lightNodeBean.getNodeNum());
                        tv_yesterday.setText(lightNodeBean.getYesterdayMoney());
                        tv_teamSmallNum.setText(lightNodeBean.getTeamMoney());
                        tv_teamSmallValue.setText("$" + lightNodeBean.getTeamValue());
                        tv_nodeLevel.setText(lightNodeBean.getNodeLevel());
                    }
                }

                @Override
                public void onFailure(String msg, int responseFailCode) {
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void initAction() {

    }
}
